home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12898 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: solon.com!not-for-mail
  2. From: nsmart@indigo.ie (Niall Smart)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
  4. Subject: Re: C coding problem
  5. Date: 3 Apr 1996 07:09:43 -0600
  6. Organization: None
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4jttan$3gf@solutions.solon.com>
  10. References: <4ianbf$h86@solutions.solon.com> <4iemcl$a05@solutions.solon.com> <4io1io$no4@solutions.solon.com> <4j06na$808@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12. X-Newsreader: Forte Free Agent 1.0.82
  13.  
  14.  
  15. >: I recently wrote a loop that went like this:
  16.  
  17. >: while (p < end_p)
  18. >:     ++*p++;
  19.  
  20. >: Maybe some will find it a counter-example; I think it's good
  21. >: code that embodies the way C is designed to work.  Arrays are
  22. >: second rate objects in C.  Use pointers.
  23.  
  24. That code scores negative for maintainability, why use arcane
  25. features of the language that can be replaced with more readable code?
  26. If you read any of the books on writing good code you will find
  27. hundreds of reasons to avoid code like that. The execution time you
  28. *might* be saving is offset many times by the time it takes a
  29. maintainer to figure it out.
  30.  
  31. Secondly, why not use arrays? In many places they are easier to
  32. understand - I for one am not going to compromise the readability
  33. of my programs because of some theoretical bull about them
  34. being second rate objects. (whatever that is intended to mean)
  35. a[i] is converted to *(a + i) by the compiler in any case so
  36. whats the advantage with your approach?
  37.  
  38. Niall
  39.